import { defineConfig } from 'vitepress'
import mdFootnote from 'markdown-it-footnote'
import mdTaskList from 'markdown-it-task-lists'
import { mdPlugin } from './config/plugins'
const config = defineConfig({
	vite: {
		// 本地运行配置，及反向代理配置
		server: {
			host: "localhost", // 指定服务器主机名
			port: 3000, // 指定服务器端口
			open: true, // 在服务器启动时自动在浏览器中打开应用程序
			strictPort: false, // 设为 false 时，若端口已被占用则会尝试下一个可用端口,而不是直接退出
			https: false, // 是否开启 https
			cors: true, // 为开发服务器配置 CORS。默认启用并允许任何源
			proxy: {
			
			}
		},
		plugins: [
			// pagefindPlugin({
			// 	btnPlaceholder: '搜索',
			// 	placeholder: '搜索文档',
			// 	emptyText: '空空如也',
			// 	heading: '共: {{searchResult}} 条结果',
			// 	// customSearchQuery: chineseSearchOptimize,
			// 	customSearchQuery(input) {
			// 		// 将搜索的每个中文单字两侧加上空格
			// 		return input
			// 			.replace(/[\u4e00-\u9fa5]/g, ' $& ')
			// 			.replace(/\s+/g, ' ')
			// 			.trim()
			// 	},
			// }),
		],
	},
	base: '/',
	lang: 'zh-CN',
	// 网站标题，左上角以及meta标题
	title: '九州通物流',
	description: 'Vite & Vue 驱动的静态站点生成器',
	cleanUrls: true,
	// sitemap: {
	// 	hostname: 'https://vanchkong.github.io',
	// 	transformItems(items) {
	// 		return items.filter((item) => !item.url.includes('migration'))
	// 	},
	// },
	// 是否忽略死链
	ignoreDeadLinks: false,
	// 最后更新于 开关
	lastUpdated: true,
	head: [
		['link', { rel: 'icon', href: '//logo.ico' }],
		['script', { src: '../js/iconfont.js', async: true, defer: true  }],
		['meta', { name: 'google-site-verification', content: 'Wzz07XeBKMnNRNwUcsw6hEgpGoTkggTxORUtLRm6rns' }],
	],
	// markdown配置
	markdown: {
		lineNumbers: true,
		// linkify: false,
		headers: {
		  level: [0, 0],
		},
		// light: #f9fafb, dark: --vp-code-block-bg
		theme: { light: 'github-light', dark: 'github-dark' },
		config: (md) => {
			md.use(mdFootnote)
			md.use(mdTaskList)
			md.use(mdPlugin)
		}
	  },
	//  主题配置
	themeConfig: {
		lastUpdated: {
			text: '最近更新时间',
			formatOptions: {
				dateStyle: 'short',
				timeStyle: 'medium',
			},
		},
		darkModeSwitchLabel: '主题',
		sidebarMenuLabel: '菜单',
		returnToTopLabel: '回到顶部',
		langMenuLabel: '多语言',
		externalLinkIcon: true,
		// aside: false,
		outlineTitle: '当前页',
		// 显示层级
		// outline: 'deep',
		logo: '/logo.ico',
		// lastUpdatedText: '最近更新时间',
		siteTitle: '云仓组件库',
		// siteTitle: false, // 不显示标题
		// 上一页下一页文本
		docFooter: {
			prev: '上一篇',
			next: '下一篇',
		},
		// 顶部导航nav
		nav: [
			{ text: '接入指南', link: '/guide/shejichuzhong', activeMatch: '/guide/' },
			{ text: '组件配置', link: '/components/button', activeMatch: '/components/' },
			// { text: '指令配置', link: '/directives/index', activeMatch: '/directives/' },
			// { text: 'Hooks配置', link: '/hooks/index', activeMatch: '/hooks/' },
      		// { text: '版本日志', link: '/versionLog/v1.0.2.html', activeMatch: '/versionLog/' },
			// {
			// 	text: pkg.version,
			// 	items: [
			// 		// { text: 'itemA', link: '/item-1' },
			// 		{ text: '更新日志', link: 'https://github.com/vuejs/vitepress/blob/main/CHANGELOG.md' },
			// 		{ text: '贡献', link: 'https://github.com/vuejs/vitepress/blob/main/.github/contributing.md' },
			// 	],
			// },
		],
		// 侧边导航

		sidebar: {
			'/guide/': sidebarGuide(),
			'/components/': sidebarComponents(),
			'/directives/': sidebarDirectives(),
			'/hooks/': sidebarHooks(),
			'/versionLog/': sidebarVersionLog(),
		},
		// 社交媒体跳转
		socialLinks: [
			{ icon: 'github', link: 'https://github.com/vanchKong/VitePressCN' },
			// { icon: 'twitter', link: '...' },
			// 还可以自定义icon
			// {
			//   icon: {
			//     svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Dribbble</title><path d="M12...6.38z"/></svg>'
			//   },
			//   link: '...'
			// }
		],
		// 每个页面页脚的编辑此页  :path  为当前路由
		// editLink: {
		// 	text: '在GitHub上编辑此页',
		// 	pattern: 'https://github.com/vanchKong/VitePressCN/edit/main/docs/:path',
		// },

		footer: {
			message: 'Released under the MIT License.',
			copyright: 'Copyright 2023 www.56jzt.com',
		},
		// carbonAds: {
		// 	code: 'CEBDT27Y',
		// 	placement: 'vuejsorg',
		// },
		search: {
			provider: 'local',
		},

		// algolia: {
		// 	appId: '7WHRITCBT0',
		// 	apiKey: '066b52245563aa4ce21dad2b4c4b96c4',
		// 	indexName: 'vitepressCN',
		// 	placeholder: '请输入关键词',
		// 	buttonText: '搜索',
		// },
	},

	buildEnd(siteConfig) {
		// console.log(siteConfig)
	},
	transformHead(ctx) {
		// console.log(1111, ctx)
	},
})
function sidebarGuide() {
	return [
		// 匹配不同路由，侧边导航有所变化，如果没有多页面需求，可以只写一个数组
		// link 字段以 / 开头，该根目录为 /docs/ 目录
		{
			text: '介绍',
			// 是否可收起
			// 初始折叠状态 true 为折叠
			// collapsed: false,
			items: [
				// { text: 'demo-button', link: '/guide/demo-button' },
				{ text: '设计初衷', link: '/guide/shejichuzhong' },
				{ text: '使用安装', link: '/guide/shiyonganzhuang' },
				{ text: '快速开始', link: '/guide/kuaisukaishi' },
				{ text: '按需引入', link: '/guide/anxuyinru' },
			],
		},
		{
			text: '本地开发',
			// collapsed: false,
			items: [
				{ text: '编写组件', link: '/guide/bianxiezujian' },
				{ text: '本地调试', link: '/guide/benditiaoshi' },
				{ text: '编写API文档', link: '/guide/bianxieAPI' },
				{ text: '打包构建', link: '/guide/dabaogoujian' },
				// { text: '上传到npm仓库', link: '/guide/shangchuanNPM' },
				{ text: '发布组件文档', link: '/guide/fabuDOC' },
			],
		},
		{
			text: '组件示例 & API 参考',
			link: '/components/button',
		},
	]
}
function sidebarHooks(){
	return [
		{
			text: 'Hooks',
			// 是否可收起
			// 初始折叠状态 true 为折叠
			// collapsed: false,
			items: [
				{ text: '使用介绍', link: '/hooks/index' },
				{
					text: '示例demo',
					items:[
						{ text: 'useClickAway 元素外点击', link: '/hooks/useClickAway' },
					]
				}
			],
		},
	]
}
function sidebarDirectives(){
	return [
		{
			text: '指令',
			// 是否可收起
			// 初始折叠状态 true 为折叠
			// collapsed: false,
			items: [
				{ text: '使用介绍', link: '/directives/index' },
				{
					text: '示例demo',
					items:[
						{ text: 'v-permission 权限', link: '/directives/permission' },
						{ text: 'v-infinite-scroll 无限滚动', link: '/directives/infinite-scroll' },
					]
				}
			],
		},
	]
}
function sidebarComponents() {
	return [
		{
			text: '组件配置',
			items: [
				{
					text: '基础组件',
					collapsed: false,
					items: [
						{ text: 'jzt-button', link: '/components/button' },
						{ text: 'jzt-input', link: '/components/input' },
						{ text: 'jzt-input-number', link: '/components/input-number' },
						
						{ text: 'jzt-switch', link: '/components/switch' },
						{ text: 'jzt-checkbox', link: '/components/checkbox' },
						{ text: 'jzt-select', link: '/components/select' },
						{ text: 'jzt-tree', link: '/components/tree' },
						{ text: 'jzt-tree-select', link: '/components/tree-select' },
						{ text: 'jzt-tooltip', link: '/components/tooltip' },

						{ text: 'jzt-date-picker', link: '/components/date-picker' },
						{ text: 'jzt-date-picker-range', link: '/components/date-picker-range' },
						{ text: 'jzt-time-select', link: '/components/time-select' },
						
						{ text: 'jzt-collapse', link: '/components/collapse' },

						{ text: 'jzt-icon', link: '/components/icon' },
						{ text: 'jzt-svg', link: '/components/svg' },

						{ text: 'jzt-dropdown', link: '/components/dropdown' },
						{ text: 'jzt-breadcrumb', link: '/components/breadcrumb' },
						{ text: 'jzt-empty', link: '/components/empty' },
						
					],
				},
				{
					text: '高级组件',
					collapsed: true,
					items: [
						// { text: 'condition', link: '/components/condition' },
						// { text: 'table', link: '/components/table' },
					],
				},
				// {
				// 	text: '交互组件',
				// 	collapsed: false,
				// 	items: [
				// 		{ text: 'Message 消息提示', link: '/components/message' },
				// 	],
				// },
				// {
				// 	text: '业务组件',
				// 	collapsed: false,
				// 	items: [
				// 		{ text: 'warehouseTable 仓库表格', link: '/components/warehouseTable' },
				// 	],
				// },
			],
		},
	]
}

function sidebarVersionLog(){
	return [
		{
			text:'日志',
			items:[
				{ text: 'v1.0.2', link: '/versionLog/v1.0.2.html' },
				{ text: 'v1.0.1', link: '/versionLog/v1.0.1.html' },
				{ text: 'v1.0.0', link: '/versionLog/v1.0.0.html' },
			]

		}
	]
}
export default config